Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add from __future__ import annotations using Ruff/isort #7631

Merged
merged 3 commits into from
Dec 22, 2023

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Dec 21, 2023

Helps #2625.

Adds the from __future__ import annotations to all files, and will ensure it's added for new files too, so we can use newer type annotations for older Pythons.

For example, use list and tuple directly instead of first from typing import List, Tuple.

@radarhere
Copy link
Member

I see you've added it to the test suite as well. I would have thought that the goal of #2625 was to add type hints to user-facing code. Or are you suggesting that expecting that we will eventually use type hints for their own sake?

@hugovk
Copy link
Member Author

hugovk commented Dec 21, 2023

User-facing code is the primary focus, but typing tests can also be beneficial, especially if it helps evaluate how the typed production code is used, and if it helps us find bugs in tests.

See also https://sethmlarson.dev/tests-arent-enough-case-study-after-adding-types-to-urllib3#type-your-tests

src/PIL/JpegPresets.py Outdated Show resolved Hide resolved
@radarhere radarhere merged commit e9453a7 into python-pillow:main Dec 22, 2023
57 checks passed
@hugovk hugovk deleted the future-annotations branch December 22, 2023 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants